#include("/template/common/layout/_page_layout.html")
#@layout()

#define css()
<style>
    button {
        background: #758ef0;
        color: #FFF;
        border: none;
        border-radius: 15px;
    }
</style>
#end

#define js()
<script type="text/javascript">
    layui.use(['form', 'layer', 'layedit'], function () {
        var form = layui.form
            , layedit = layui.layedit
            , $ = layui.jquery;
        //监听提交
        form.on('submit(demo1)', function (data) {
            util.sendAjax({
                type: 'POST',
                url: '#(ctxPath)/app/information/diagnosesSave',
                data: $('#Form').serialize(),
                loadFlag: true,
                success: function (data) {
                    window.location.href = document.referrer;
                }
            });
        });
        var element = '#(diagnoses.toJson())';
        var diagnoses = JSON.parse(element);
        $("#surveyGroup").text(diagnoses.surveyGroup).css("display", "").removeClass("layui-hide");
        $("#surveyDesign").text(diagnoses.surveyDesign).css("display", "").removeClass("layui-hide");
        $("#surveyMethod").val(diagnoses.surveyMethod);
        if (diagnoses.surveyWay != null) {
            $("input[name='surveyWays']").each(function () {
                if (diagnoses.surveyWay.indexOf($(this).val()) != -1) {
                    $(this).prop("checked", true);
                }
            });
        }
        if (diagnoses.staffArrangements != null) {
            $("input[name='staffArrangements']").each(function () {
                if (diagnoses.staffArrangements.indexOf($(this).val()) != -1) {
                    $(this).prop("checked", true);
                }
            });
        }
        form.render('checkbox');
        form.render('select');
        //自定义工具栏
        var surveyGroupedit = layedit.build('surveyGroup', {
            tool: ['left', 'center', 'right'],
            height: 100
        });
        //自定义工具栏
        var surveyDesignedit = layedit.build('surveyDesign', {
            tool: ['left', 'center', 'right'],
            height: 100
        });

        var flag = '#(flag)';
        if (flag === "true") {
            $('#sub').remove();
            $('input').addClass('layui-disabled').attr("disabled", "disabled");
        }

        form.verify({
            surveyDesignedit: function (vale) {
                layedit.sync(surveyDesignedit); //同步编辑内容到textarea #10line
                if (layedit.getContent(surveyDesignedit).length == 0) {
                    return "问卷调查设计不能为空";
                }
            },

            surveyGroupedit: function (vale) {
                layedit.sync(surveyGroupedit); //同步编辑内容到textarea #10line
                if (layedit.getContent(surveyGroupedit).length == 0) {
                    return "调查群体不能为空";
                }
            },
            sampleRateNumber: function (vale) {
                if (vale >= 100) {
                    return "数值不能大于100"
                }

            }


        });
    });

    function pdf(element) {
        element.media({
            width: 800
            , height: 600
            , src: element.attr('href')
        });
    }

    $("#media").click(function () {
        $(this).css('display', 'none');
        pdf($("a.media"));
    });

    $("#reset").click(function () {
        history.go(-1);
    });
</script>
#end

#define content()
<br>
<h2 class="title" align="center">社会稳定风险评估调查分析表</h2><br>
<hr align="center" size="2" width="100%"/>

<div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
    <!-- <ul class="layui-tab-title"> -->
    <!-- <li class="layui-this">项目基本信息</li> -->
    <!-- <li>问卷基本信息</li> -->
    <!-- <li>调查内容</li> -->

    <!-- </ul> -->


    <div class="layui-tab-item layui-show">
        <form class="layui-form" id="Form">
            <input class="layui-hide" value="#(diagnoses.id)" name="diagnoses.id">
            <div style="padding: 20px; background-color: #F2F2F2;">
                <div class="layui-row layui-col-space15">
                    <div class="layui-col-md12">
                        <div class="layui-card">
                            <div class="layui-card-header">项目基本信息</div>
                            <div class="layui-card-body">
                                <div class="layui-row">
                                    <div class="layui-col-md6">
                                        <div class="layui-form-item">
                                            <label class="layui-form-label" style="width:100px;">评估项目名称：</label>
                                            <div class="layui-input-block">
                                                <input type="text" name="diagnoses.name" autocomplete="off" placeholder="系统读取"
                                                       value="#(project.name)" class="layui-input" readonly="readonly" style="width:350px; position: absolute; left: 20px;">
                                                <input type="text" name="diagnoses.project" autocomplete="off" placeholder="系统读取"
                                                       value="#(project.id)" class="layui-input layui-hide" style="width:400px;position: absolute; left: 20px;">
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-col-md6">
                                        <div class="layui-form-item">
                                            <label class="layui-form-label" style="width:100px;">负责评估机构：</label>
                                            <div class="layui-input-block">
                                                <input type="text" autocomplete="off" placeholder="系统读取"
                                                       value="#(organization.name)" class="layui-input" readonly="readonly" style="width:350px; position: absolute; left: 20px;">
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-col-md12">
                                        <div class="layui-form-item">
                                            <label class="layui-form-label" style="width:100px;">项目地址：</label>
                                            <div class="layui-input-block">
                                                <input type="text" name="diagnoses.project.site" autocomplete="off" placeholder="系统读取"
                                                       value="#(project.site)" class="layui-input" readonly="readonly" style="width:855px; position: absolute; left: 20px;">
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="layui-row layui-col-space15">
                    <div class="layui-col-md12">
                        <div class="layui-card">
                            <div class="layui-card-header">调查基本信息</div>
                            <div class="layui-card-body">
                                <div class="layui-row">
                                    <div class="layui-col-md4">
                                        <div class="layui-form-item">
                                            <label class="layui-form-label" style="width:100px;margin-left: 18px;">调查方法：</label>
                                            <div class="layui-input-inline">
                                                <label>
                                                    <select lay-verify="required" name="diagnoses.surveyMethod" id="surveyMethod">
                                                        <option value="">请选择</option>
                                                        <option value="全面调查">全面调查</option>
                                                        <option value="抽样调查">抽样调查</option>
                                                        <option value="个别调查">个别调查</option>
                                                    </select>
                                                </label>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-col-md5">
                                        <div class="layui-form-item layui-form-text" >
                                            <label class="layui-form-label" style="width:100px;">调查抽样率：</label>
                                            <div class="layui-input-block">
                                                <input type="number" lay-verify="required|sampleRateNumber" class="layui-input"
                                                       name="diagnoses.sampleRate" value="#(diagnoses.sampleRate)" min=0 max=100 style="width:190px;">
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-col-md12">
                                        <div class="layui-form-item">
                                            <label class="layui-form-label" style="width:100px;margin-left: 18px;" >调查方式：</label>
                                            <input type="checkbox" name="surveyWays" value="走访" title="走访" style="margin-left: 135px;">
                                            <input type="checkbox" name="surveyWays" value="座谈" title="座谈" style="margin-left: 135px;">
                                            <input type="checkbox" name="surveyWays" value="听证会" title="听证会" style="margin-left: 135px;">
                                            <input type="checkbox" name="surveyWays" value="电话调查" title="电话调查" style="margin-left: 135px;">
                                            <input type="checkbox" name="surveyWays" value="邮件询问" title="邮件询问" style="margin-left: 135px;">
                                        </div>
                                    </div>
                                    <div class="layui-col-md12">
                                        <div class="layui-form-item">
                                            <label class="layui-form-label" style="width:120px;">现场人员安排：</label>
                                            <div class="layui-input-block">
                                                #for (invTeamID : invTeamMap.keySet())
                                                <input type="checkbox" name="staffArrangements" value="#(invTeamID)"
                                                       title="#(invTeamMap[invTeamID])" style="margin-left: 13px;">
                                                #end
                                            </div>
                                        </div>
                                    </div>

                                    <div class="layui-form-item">
                                        <label class="layui-form-label" style="width:100px;margin-left: 18px; ">调查范围：</label>
                                        <div class="layui-input-block">
                                            <input type="text" name="diagnoses.surveyFieldFileID" autocomplete="off" placeholder="系统读取"
                                                   value="#(files.id)" class="layui-input layui-hide" style="margin-left: 135px;">
                                            <a class="media" href="#(files.path)" readonly="readonly"></a>
                                            <a class="layui-btn" id="media">点击查看</a>
                                            <button id="pdf"></button>
                                        </div>
                                    </div>

                                    <div class="layui-form-item layui-form-text">
                                        <label class="layui-form-label" style="width:100px;margin-left: 18px;">调查群体：</label>
                                        <div class="layui-input-block " style="margin-left:148px;width: 935px;">
                        <textarea id="surveyGroup" lay-verify="surveyGroupedit" placeholder="请填写"
                                  name="diagnoses.surveyGroup"
                                  class="layui-textarea">#(diagnoses.surveyGroup)</textarea>
                                        </div>
                                    </div>

                                    <div class="layui-form-item layui-form-text">
                                        <label class="layui-form-label" style="width:100px;margin-left: 18px;">问卷调查设计：</label>
                                        <div class="layui-input-block" style="margin-left:148px;width:935px;">
                        <textarea id="surveyDesign" placeholder="请填写" class="layui-textarea"
                                  lay-verify="surveyDesignedit"
                                  name="diagnoses.surveyDesign">#(diagnoses.surveyDesign)</textarea>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>


<div style="text-align: center">
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button type="button" class="layui-btn" lay-submit="" lay-filter="demo1" id="sub">提交</button>
            <button type="button" class="layui-btn layui-btn-primary" id="reset">返回</button>
        </div>
    </div>
</div>
#end